<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@page import="com.cs.beneficios.common.ConnectionFactory, com.cs.beneficios.common.entity.Consultas,java.sql.ResultSet,com.cs.beneficios.common.entity.database,java.util.Vector,com.cs.paoyer.administration.business.model.UserVO,java.text.SimpleDateFormat,java.util.Calendar"%>
<link href="<%= request.getContextPath() + "/css/bloques.css" %>" rel="stylesheet" type="text/css">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>ActivarCorrecta</title>
  </head>
  <form>
  <body>
    <P></P>
    <P></P>

<%
  database db = new database();
  Vector codsub = new Vector ();
  int modificar;
  ResultSet rs = null;
  String strcod = "";
  String strcod1 = "";
  //ConnectionFactory cf = new ConnectionFactory("beneficios","beneficios");
  ConnectionFactory cf = new ConnectionFactory();
  Consultas consulta = new Consultas(cf); 
  String strcont = request.getParameter("cont");
  int cont =Integer.parseInt(strcont.trim());
  int i=0;
  for(i=0; i<cont; i++){
   String activar = request.getParameter("Activar"+i);
      if(activar != null){
       //Proceso para la auditoria
        UserVO user = (UserVO) request.getSession().getAttribute("userInfo");
        String terminalAddress = request.getRemoteAddr();
        String strTerminal = ("WEB="+terminalAddress);
        Calendar c = Calendar.getInstance(); 
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");   
        //Fin del proceso
        String strArr[] = {user.getName(), dateFormat.format(c.getTime()),strTerminal,activar};

       modificar = consulta.getActivarPro2(strArr);   
       codsub.addElement (activar);
       }
  } 
      if(codsub.size() == 1){%>
          
           <P align="center">&nbsp;</P>
     <table cellspacing="3" cellpadding="3" border="0" width="100%" align="center">
          <tr>
            <td width="28%">&nbsp;</td>
            <td class="titulosenblanco" width="53%" >
              <FONT size="4">El Programa </FONT></td>
            <td width="19%">&nbsp;</td>
          </tr>
        <%for (i = 0; i < codsub.size (); i++){
             strcod = (String)codsub.get(i);
            rs = consulta.getNomPrg(strcod); 
            while(rs.next()){%>      
          <tr>
            <td width="28%">&nbsp;</td>
            <td class="celdatabla" width="53%" align="center"><%=rs.getString("nombre")%></td>
            <td width="19%">&nbsp;</td>
          </tr>
            <%}
          }%>
          <tr>
            <td width="28%">&nbsp;</td>
            <td class="titulosenblanco" width="53%">
              <FONT size="3"><FONT size="4">fue activado... </FONT></FONT></td>     
            <td width="19%">&nbsp;</td>
          </tr>
          <tr>
        <td width="28%">&nbsp;</td>
        <td width="28%">&nbsp;</td>
       <td> 
          <a href="<%=request.getContextPath()+"/subprogramas/ActivarSubprogramas.do?ori=activar&programa="+strcod %>">
          <img src="<%= request.getContextPath() + "/images/activar.gif" %>" alt="Activar" width="22" height="22" border="0"/>
           <br/>
          <span>Activar Subprogramas</span>
          </a></td>
      </tr>
        </table>     
  <% }else{ %>
    <P align="center">&nbsp;</P>
    <table cellspacing="3" cellpadding="3" border="0" width="100%" align="center">
      <tr>
        <td width="28%">&nbsp;</td>
        <td class="titulosenblanco" width="53%">
          <FONT size="4">Los Programas </FONT></td>
        <td width="19%">&nbsp;</td>
      </tr>
    <%for (i = 0; i < codsub.size (); i++){
        strcod = (String)codsub.get(i);
        rs = consulta.getNomPrg(strcod);  
        while(rs.next()){%>      
      <tr>
        <td width="28%">&nbsp;</td>
        <td class="celdatabla" width="53%" align="center"><%=rs.getString("nombre")%></td>
        <td width="19%">&nbsp;</td>
      </tr>
        <%}
      }%>
      <tr>
        <td width="28%">&nbsp;</td>
        <td class="titulosenblanco" width="53%">
          <FONT size="4">fueron activados... </FONT></td>
        <td width="19%">&nbsp;</td>
      </tr>
      <tr>
        <td width="28%">&nbsp;</td>
        <td width="28%">&nbsp;</td>
        <td width="28%"> <a href="<%=request.getContextPath()+"/programas/ConsultarPrograma.do"%>"><img src="<%=request.getContextPath() + "/images/BACK1-1.gif"%>" border="0"/></a></td>
      </tr>
    </table>
 <%}%>
 </body>
  </form>
</html>
